package com.example.yeujian5.yuejian5.fragment;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.yeujian5.yuejian5.Listenner.UserAllOrderListener;
import com.example.yeujian5.yuejian5.R;
import com.example.yeujian5.yuejian5.adapter.UserComOrderListAdapter;
import com.example.yeujian5.yuejian5.bean.UserOrder;
import com.example.yeujian5.yuejian5.model.UserModel;

import java.util.List;

/**

 */
public class ComOrderFragment extends Fragment  implements UserAllOrderListener {
    private RecyclerView recyclerView;
    private String userid;
    List<UserOrder> list;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View view = inflater.inflate(R.layout.fragment_com_order,container,false);
        recyclerView = (RecyclerView) view.findViewById(R.id.comorder_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));//设置布局
        userid = getActivity().getSharedPreferences("Userid", Context.MODE_PRIVATE).getString("user_id", String.valueOf(0));
        Log.v("ComOrder获取用户id", String.valueOf(userid));
        showData();
        return view;
    }
    private void showData(){
        UserModel model=new UserModel();
        model.getOrderByType(userid,String.valueOf(1),this);
    }

    @Override
    public void onResponse(List<UserOrder> listBean) {
        list=listBean;
        recyclerView.setAdapter(new UserComOrderListAdapter(getActivity(),list));
    }

    @Override
    public void onFail(String msg) {

    }
}
